#include "sActionHandler.h"
#include "sComponentInstance.h"
#include "sComponentRectInstance.h"
#include "sGUI.h"

namespace sgui
{
namespace inst
{
    
sComponentInstance* sActionHandler::getInstance()
{
    return m_instance;
}

const sComponentInstance* sActionHandler::getInstance() const
{
    return m_instance;
}
    
sComponentRectInstance* sActionHandler::getCaller() 
{ 
    return m_caller; 
}
    
bool sActionHandler::update(double dt)
{
    return false;
}
	
bool sActionHandler::notifyInstance(const sActionHandlerEvent& event)
{
	return getInstance()->OnHandlerEvent(event);
}
    
void sActionHandler::release(const obs::sMouseEvent* event)
{
    getInstance()->getGui().setHandler(NULL, event);
}

sActionHandler::sActionHandler(sComponentInstance* instance, sComponentRectInstance *caller) :
    m_instance(instance), m_caller(caller)
{
    m_activeRect = math::sRectf(getCaller()->getOffset() + getCaller()->getRect().getPosition(), getCaller()->getRect().getSize());
}
    
sActionHandler::~sActionHandler()
{
	//
}

};
};